package com.exam.sacrifice.ui.baijiaxing;

import android.view.View;

import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.exam.commonbiz.base.BaseActivity;
import com.exam.commonbiz.base.BaseViewModel;
import com.exam.commonbiz.util.OnFastClickListener;
import com.exam.sacrifice.R;
import com.exam.sacrifice.databinding.ActivityBaiJiaXingDetailBinding;

public class BaiJiaXingDetailActivity extends BaseActivity<BaseViewModel, ActivityBaiJiaXingDetailBinding> {

    private QiYuanFragment qiYuanFragment;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_bai_jia_xing_detail;
    }

    @Override
    public void initData() {

        binding.include.tvTitle.setText("详情");
        binding.include.ivback.setOnClickListener(new OnFastClickListener() {
            @Override
            public void onFastClick(View v) {
                back();
            }
        });

        selectFragment(0);
    }

    public void selectFragment(int position) {//设置传入第几值显示第几个fragment
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();

        switch (position) {
            case 0:
                if (qiYuanFragment == null) {
                    qiYuanFragment = QiYuanFragment.newInstance();
                }
                ft.replace(R.id.fragment_root, qiYuanFragment);
                break;
            case 1:
                if (qiYuanFragment == null) {
                    qiYuanFragment = QiYuanFragment.newInstance();
                }
                ft.replace(R.id.fragment_root, qiYuanFragment);
                break;
            case 2:
                if (qiYuanFragment == null) {
                    qiYuanFragment = QiYuanFragment.newInstance();
                }
                ft.replace(R.id.fragment_root, qiYuanFragment);
                break;
            default:
                break;
        }
        ft.commit();
    }
}